<?php 
require '../../vendor/autoload.php';

use database\DnFile;
use utils\PathTool;
use model\DnFileInf;

$uid     = $_GET["uid"];
$id      = $_GET["id"];
$f_id  	 = $_GET["f_id"];
$nameLoc = $_GET["nameLoc"];
$pathLoc = $_GET["pathLoc"];;
$fileUrl = $_GET["fileUrl"];
$lenSvr  = $_GET["lenSvr"];
$sizeSvr = $_GET["sizeSvr"];
$cbk     = $_GET["callback"];
$pathLoc = PathTool::url_decode($pathLoc);
$nameLoc = PathTool::url_decode($nameLoc);

if (  strlen($uid) < 1
	||empty($pathLoc)
	||empty($fileUrl)
	||empty($lenSvr))
{
	echo cbk . "({\"value\":null})";
	die();
}

$inf          = new DnFileInf();
$inf->id      = $id;
$inf->f_id    = $f_id;
$inf->uid     = $uid;
$inf->nameLoc = $nameLoc;
$inf->pathLoc = $pathLoc;
$inf->fileUrl = $fileUrl;
$inf->lenSvr  = intval($lenSvr);
$inf->sizeSvr = $sizeSvr;

$df = new DnFile();
$df->Add($inf);

//防止jsonencode将汉字转换为unicode
$inf->nameLoc = PathTool::urlencode_safe($inf->nameLoc);
$inf->pathLoc = PathTool::urlencode_safe($inf->pathLoc);
$json         = json_encode($inf);
$json         = urldecode($json);//还原汉字
$json         = urlencode($json);
$json         = "$cbk({\"value\":\"$json\"})";//返回jsonp格式数据。
echo $json;
?>